#页面类
from Day17zy.Base import Base
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from time import sleep
class Page(Base):
    #页面元素
    # #输入账号
    # username=(By.NAME,'userName')
    # #输入密码
    # password=(By.CLASS_NAME,'form-control')
    #点击登录
    button=(By.XPATH,'//*[@id="but_login"]/span')
    #点击每日检查
    jiancha=(By.XPATH,'//*[@id="sidebar"]/ul/li[2]/a')
    #选择收货未上架
    shouhuo=(By.XPATH,'//*[@id="sidebar"]/ul/li[2]/ul/li[1]/a')
    #框架
    fame=(By.XPATH,'//*[@id="tab_402881885f450361015f4752f3690065"]/iframe')
    #托盘
    tuopan=(By.NAME,'tin_id')
    #客户编码
    bianhao=(By.NAME,'cus_code')
    #客户名称
    name=(By.NAME,'zhong_wen_qch')
    #商品编码
    shop=(By.XPATH,'//*[@id="wm_tuopanListtb"]/div[1]/span[5]/input')
    #商品名称
    shopname=(By.NAME,'shp_ming_cheng')
    #点击查询
    find=(By.PARTIAL_LINK_TEXT,'查询')
    #点击重置
    chongzhi=(By.CLASS_NAME,'l-btn-text icon-reload l-btn-icon-left')

    #业务执行
    def search(self):
        sleep(10)
        # 点击登录
        self.click(self.button)
        sleep(2)
        #点击每日检查
        self.click(self.jiancha)
        sleep(5)
        # 选择收货未上架
        self.click(self.shouhuo)
        sleep(2)
        #进入框架
        self.switch_to_frame(self.fame)
        # 托盘
        self.send_keys(self.tuopan,'A')
        sleep(2)
        # 客户编码
        self.send_keys(self.bianhao, '001')
        sleep(2)
        # 客户名称
        self.send_keys(self.name, '马云')
        sleep(2)
        # 商品编码
        self.send_keys(self.shop, 'spbm001')
        sleep(4)
        # 商品名称
        self.send_keys(self.shopname, 'spbm001-猕猴桃-箱')
        sleep(4)
        # 点击查询
        self.click(self.find)
        sleep(2)
        # 点击重置
        self.click(self.chongzhi)
        sleep(2)


    #业务逻辑
    def text(self):

        self.open_url('http://10.59.9.32/jeewms/')
        self.search()
        sleep(10)
